﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace IntroMVC4.Areas.AnnaKids.Models
{
    public class BaseAdminController : Controller
    {
        [Authorize(Roles = "Admin")]
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!Request.IsAuthenticated)
            {
                string redirectOnSuccess = filterContext.HttpContext.Request.Url.AbsolutePath;
                string redirectUrl = string.Format("?ReturnUrl={0}", redirectOnSuccess);
                string loginUrl = FormsAuthentication.LoginUrl + redirectUrl;
                filterContext.Result = new RedirectResult(loginUrl);
                //return RedirectToAction("LogOn", "Account");
            }
        }
    }
}